package com.hjm.project.record.activityRecord.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import com.hjm.framework.aspectj.lang.annotation.Log;
import com.hjm.framework.aspectj.lang.enums.BusinessType;
import com.hjm.project.record.activityRecord.domain.ActivityUpdateRecord;
import com.hjm.project.record.activityRecord.service.IActivityUpdateRecordService;
import com.hjm.framework.web.controller.BaseController;
import com.hjm.framework.web.domain.AjaxResult;
import com.hjm.common.utils.poi.ExcelUtil;
import javax.annotation.Resource;
import com.hjm.framework.web.page.TableDataInfo;

/**
 * 活动变更修改记录Controller
 * 
 * @author maker-platform
 * @date 2022-10-31
 */
@Controller
@RequestMapping("/record/activityRecord")
public class ActivityUpdateRecordController extends BaseController {
    private String prefix = "record/activityRecord";

    @Resource
    private IActivityUpdateRecordService activityUpdateRecordService;

    @RequiresPermissions("record:activityRecord:view")
    @GetMapping()
    public String activityRecord() {
        return prefix + "/activityRecord";
    }

    /**
     * 查询活动变更修改记录列表
     */
    @RequiresPermissions("record:activityRecord:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ActivityUpdateRecord activityUpdateRecord) {
        startPage();
        List<ActivityUpdateRecord> list = activityUpdateRecordService.selectActivityUpdateRecordList(activityUpdateRecord);
        return getDataTable(list);
    }

    /**
     * 导出活动变更修改记录列表
     */
    @RequiresPermissions("record:activityRecord:export")
    @Log(title = "活动变更修改记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ActivityUpdateRecord activityUpdateRecord) {
        List<ActivityUpdateRecord> list = activityUpdateRecordService.selectActivityUpdateRecordList(activityUpdateRecord);
        ExcelUtil<ActivityUpdateRecord> util = new ExcelUtil<ActivityUpdateRecord>(ActivityUpdateRecord.class);
        return util.exportExcel(list, "activityRecord");
    }

    /**
     * 新增活动变更修改记录
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存活动变更修改记录
     */
    @RequiresPermissions("record:activityRecord:add")
    @Log(title = "活动变更修改记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ActivityUpdateRecord activityUpdateRecord) {
        return toAjax(activityUpdateRecordService.insertActivityUpdateRecord(activityUpdateRecord));
    }

    /**
     * 修改活动变更修改记录
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Integer id, ModelMap mmap) {
        ActivityUpdateRecord activityUpdateRecord = activityUpdateRecordService.selectActivityUpdateRecordById(id);
        mmap.put("activityUpdateRecord", activityUpdateRecord);
        return prefix + "/edit";
    }

    /**
     * 修改保存活动变更修改记录
     */
    @RequiresPermissions("record:activityRecord:edit")
    @Log(title = "活动变更修改记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ActivityUpdateRecord activityUpdateRecord) {
        return toAjax(activityUpdateRecordService.updateActivityUpdateRecord(activityUpdateRecord));
    }

    /**
     * 删除活动变更修改记录
     */
    @RequiresPermissions("record:activityRecord:remove")
    @Log(title = "活动变更修改记录", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        return toAjax(activityUpdateRecordService.deleteActivityUpdateRecordByIds(ids));
    }

    @GetMapping("/activityRecordDetails")
    public String purchaserRecordDetails(@RequestParam String batch, ModelMap mmp){
        mmp.addAttribute("batch",batch);
        return prefix + "/activityRecordDetails";
    }

    /**
     * 查询活动变更修改记录列表
     */
    @RequiresPermissions("record:activityRecord:list")
    @PostMapping("/detail")
    @ResponseBody
    public TableDataInfo detail(ActivityUpdateRecord activityUpdateRecord) {
        startPage();
        List<ActivityUpdateRecord> list = activityUpdateRecordService.selectActivityUpdateRecordDetail(activityUpdateRecord);
        return getDataTable(list);
    }

    /**
     * 导出活动变更修改记录列表
     */
    @RequiresPermissions("record:activityRecord:export")
    @Log(title = "活动变更修改记录", businessType = BusinessType.EXPORT)
    @PostMapping("/exportDetail")
    @ResponseBody
    public AjaxResult exportDetail(ActivityUpdateRecord activityUpdateRecord) {
        List<ActivityUpdateRecord> list = activityUpdateRecordService.selectActivityUpdateRecordDetail(activityUpdateRecord);
        ExcelUtil<ActivityUpdateRecord> util = new ExcelUtil<ActivityUpdateRecord>(ActivityUpdateRecord.class);
        return util.exportExcel(list, "activityRecord");
    }
}
